/*
 * Copyright (C) 2010 Seapeak.Xu
 *
 * fostmq may be copied only under the terms of the GNU General
 * Public License V3, which may be found in the fostmq source kit.
 *
 * Created on: 2010-10-13
 * Author: Seapeak.Xu
 */

#ifndef FOST_NOTIFYPOOL_H
#define FOST_NOTIFYPOOL_H
#ifdef __cplusplus
extern "C"
{
#endif

#include <stdlib.h>
#include <stdio.h>
#include <event.h>
#include <unistd.h>
#include <pthread.h>

/*
 * i use the threadpool for dealing the working thread begining
 * but it has a death lock for mutex,i want to deal it with 20 days,
 * readlly i must say me "fucking,you are fool!"
 * ai!,i have to use pipe
 * readlly have no people can do with threadpool?
 * cloud,cloud,everything is cloud!
 */

typedef void (*notify_read_func)(int sock,short events,void *arg);	

typedef struct notify_elt_type
{
	struct event_base *ev_base;
	pthread_t tid;
	int pipe_fds[2];
	int idx;
	notify_read_func func;
}notify_elt_t;

notify_elt_t *g_notify_elts;

int notifypool_init(size_t max_size,notify_read_func func);
int notifypool_destroy();

#ifdef __cplusplus
}
#endif
#endif
